<?php
//echo $this->dojo();
$urlParams = array("table/Default_Model_DbTable_AuditLog");


foreach(Zend_Controller_Front::getInstance()->getRequest()->getUserParams() as $key => $value)
{
	$urlParams[] = urlencode($key) . '/' . urlencode($value);
}
$urlParams = implode('/', $urlParams);
?>
<h1><?= $this->table->getNiceName() ?> List</h1>


<div dojoType="dijit.Toolbar">
	<div dojoType="dijit.form.Button">
		<span>Add New <?= $this->table->getNiceName() ?></span>
		<script type="dojo/connect" event="onClick">
			window.location = '<?= Zend_Controller_Front::getInstance()->getBaseUrl() ?>/<?= Zend_Controller_Front::getInstance()->getRequest()->getModuleName() ?>/<?= Zend_Controller_Front::getInstance()->getRequest()->getControllerName() ?>/add/<?= str_replace('/useLayout/false', '', $urlParams)?>';
		</script>
	</div>
</div>
		
		
<span dojoType="dijit.layout.ContentPane">
<script type="dojo/connect">
viewRecord = function(e)
{
	var newUrl = '<?= Zend_Controller_Front::getInstance()->getBaseUrl() ?>/<?= Zend_Controller_Front::getInstance()->getRequest()->getModuleName() ?>/<?= Zend_Controller_Front::getInstance()->getRequest()->getControllerName() ?>/view/table/<?= $this->tableName?>/<?= current($this->table->info(Bushido_Db_Table_Abstract::PRIMARY))?>/' + this.store.getValue(this.getItem(e.rowIndex), '<?= current($this->table->info(Bushido_Db_Table_Abstract::PRIMARY))?>');
	//newModalDialog({title: 'Detail', style: 'width:770px;', href: newUrl});
	window.location=newUrl;
}
<?php
if($this->table->getGridLayout())
{
?>
	rowsetLayout = <?= Zend_Json::encode($this->table->getGridLayout()) ?>;
<?php
}
else
{
?>
rowsetLayout = 
	[
		[
<?php 
		$fields = array_keys($this->table->info('metadata'));
		foreach($fields as $field)
		{
		?>
			{field: "<?= $field ?>", name: "<?= $field ?>", width: 'auto'},
		<?php
		}
		?>
		]
	];
<?php
}
?>
</script>
</span>
<?php


?>

<span dojoType="dojo.data.ItemFileReadStore" id="gridStore" jsId="gridStore" url="<?= Zend_Controller_Front::getInstance()->getBaseUrl() ?>/<?= Zend_Controller_Front::getInstance()->getRequest()->getModuleName() ?>/<?= Zend_Controller_Front::getInstance()->getRequest()->getControllerName() ?>/json/<?= $urlParams ?>" ></span>
<div style="height:200px;"
dojoType="dojox.grid.DataGrid"
store="gridStore"
query="{}"
structure="rowsetLayout"
onRowClick="viewRecord"
rowsPerPage="40">
  </div>